package com.gurkensalat.ebooks.ebookmarksync.shared;

import java.util.List;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Strongly influenced by the example code from Locale examples,
 * <http://www.twofortyfouram.com>
 * 
 * @author Hakan Tandogan <hakan.tandogan@gmail.com>
 */
public class PackageUtilities
{
	public static boolean isPackageInstalled(String packageName, PackageManager manager)
	{
		if (packageName != null)
		{
			final List<PackageInfo> installedPackages = manager.getInstalledPackages(0);
			for (PackageInfo packageInfo : installedPackages)
			{
				if (packageName.equals(packageInfo.packageName))
				{
					return true;
				}
			}
		}

		return false;
	}
}
